/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <stack>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 2e5;

char str[maxn + 1];

char vis[maxn + 1];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cin >> (str + 1);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      cnt += str[i] == '(';
    }
    if (cnt != n - cnt) {
      cout << "-1" << '\n';
      continue;
    }
    std::stack<char> s;
    int last = 0;
    char cur = str[1];
    for (int i = 1; i <= n; ++i) {
      if (str[i] == cur) {
        s.push(str[i]);
      } else {
        if (!s.empty()) {
          s.pop();
        } else {
          for (int j = last; j < i; ++j) {
            vis[j] = cur;
          }
          last = i;
          s.push(str[i]);
          cur = (cur == '(' ? ')' : '(');
        }
      }
    }
    if (s.empty() && str[n] == (cur == '(' ? ')' : '(')) {
      for (int j = last; j <= n; ++j) {
        vis[j] = cur;
      }
    }
    int ans = 1;
    for (int i = 2; i <= n; ++i) {
      if (vis[i] != vis[i - 1]) ans = 2;
    }
    cout << ans << '\n';
    for (int i = 1; i <= n; ++i) {
      if (ans == 1) {
        cout << '1' << ' ';
      } else
        cout << (vis[i] == '(' ? '1' : '2') << ' ';
    }
    cout << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("D. Bracket Coloring.in", "r", stdin);
  freopen("D. Bracket Coloring.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
